package com.texaco.chapasFutbol.multiplayer.mensajes;

import java.util.List;
import java.util.Map;

import org.json.JSONException;

/**
 * Mensaje que implementa el envío de información de como quedan las chapas
 * y la pelota despues de un turno.
 * @author texaco
 *
 */
public class PositionsMessage extends BaseMessage{
	
	private static final long serialVersionUID = 4523918021101966792L;
	private long idMatch;
	private long idClient;
	private List<Double> capsPos;
	private List<Double> ballPos;
	
	public PositionsMessage() throws JSONException{
		super(MESSAGE_POSITIONS);
	}
	
	public PositionsMessage(String jsonStr) throws JSONException{
		super(MESSAGE_POSITIONS, jsonStr);
	}
	
	public PositionsMessage(Map<String, String> jsonMap) throws JSONException{
		super(MESSAGE_POSITIONS, jsonMap);
	}
	
	@Override
	protected void preRead() {
		try {
			idMatch = getLong(FIELD_ID_MATCH);
			idClient = getLong(FIELD_ID_CLIENT);
			capsPos = getArrayAsDouble(FIELD_LOCAL_POSITION);
			ballPos = getArrayAsDouble(FIELD_BALL_POSITION);
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	@Override
	protected void preWrite() {
		try {
			put(FIELD_ID_MATCH, idMatch);
			put(FIELD_ID_CLIENT, idClient);
			put(FIELD_LOCAL_POSITION, capsPos);
			put(FIELD_BALL_POSITION, ballPos);
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public long getIdMatch() {
		return idMatch;
	}

	public void setIdMatch(long idMatch) {
		this.idMatch = idMatch;
	}

	public long getIdClient() {
		return idClient;
	}

	public void setIdClient(long idClient) {
		this.idClient = idClient;
	}

	public List<Double> getCapsLPos() {
		return capsPos;
	}

	public void setCapsPos(List<Double> capsPos) {
		this.capsPos = capsPos;
	}


	public List<Double> getBallPos() {
		return ballPos;
	}

	public void setBallPos(List<Double> ballPos) {
		this.ballPos = ballPos;
	}
}
